/*===========================================================================================================================
	Wolf Prop Protection
		By Goluch
			DO NOT UPLOAD TO GARRYSMOD.ORG
			
			
	Name: WPP.AdminMenu
	Purpose: Creates the WPP Menu.
	Author: Goluch
===========================================================================================================================*/
hook.Add("PopulateToolMenu", "WPP-SpawnMenuOpen-Admin", function()
	spawnmenu.AddToolMenuOption("Utilities", "Admin", "WPP Admin", "Wolf Prop Protection Admin", "", "", function(Panel)
		WPP.AdminMenu = Panel //Futrue Refrence
		
		Panel.NoClip = Panel:AddControl("Button", {Text = "", Command = "wpp noclip"});
		Panel.Damage = Panel:AddControl("Button", {Text = "", Command = "wpp damage"});
		
		Panel:AddControl("Header", {Text = "\nClean Up Options"});
		
		//Panel:AddControl("Button", {Text = "Every thing", Command = "wpp "});
		Panel:AddControl("Button", {Text = "Disconected Players", Command = "wpp cleanupdisconected"});
		
		Panel.Players = {};
		
		timer.Create("WPP_Admin_Menu",1,0,function(Panel)
			for Player,PANEL in pairs ( Panel.Players ) do
				if ( !Player ) or ( !Player:IsValid() ) or ( !Player:IsPlayer() ) then
					PANEL:Remove();
					Panel.Players[Player] = nil;
				end
				
			end
			
			for _,Player in pairs ( player.GetAll() ) do
				if ( !Panel.Players[Player] ) then
					Panel.Players[Player] = Panel:AddControl("Button", {Text = Player:Nick(), Command = "wpp cleanupplayer " .. Player:UniqueID() });
					
				end
				
			end
			
			if ( Panel.NoClip ) then
				local Text = "Enable Noclip Protection";
				if ( GetConVarNumber("wpp_anti_noclip") >= 1 ) then
					Text = "Disable Noclip Protection";
				end
				
				Panel.NoClip:SetText(Text)
			end
			
			if ( Panel.Damage ) then
				local Text = "Enable Damage Protection";
				if ( GetConVarNumber("wpp_stop_damage") >= 1 ) then
					Text = "Disable Damage Protection";
				end
				
				Panel.Damage:SetText(Text)
			end
			
		end,Panel);
		
	end);
	
end);